{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>机构活动列表</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-9">
                        <form id="layuiForm">
                            <div class="col-sm-2 form-group">
                                <select  class="form-control m-b chosen-select search" name="sign_status" id="sign_status">
                                    <option  value="">全部</option>
                                    <option  value="1">未签到</option>
                                    <option  value="2">签到</option>
                                    <option  value="2">签退</option>
                                </select>
                            </div>

                            <div class="col-sm-4">
                                <div class="input-group" >
                                    <input type="text" id="key" class="form-control search" name="key" value="" placeholder="用户昵称|手机号码"/>
                                    <span class="input-group-btn">
                                        <a  class="btn btn-primary layuiBtn" data-type="reload"><i class="fa fa-search"></i> 搜索</a>
                                    </span>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Activity/member")}'
            , page: true
            , where: {id:{:session('activity_id')}}
        , even: false //开启隔行背景
                , size: 'lg' //sm小尺寸的表格 lg大尺寸
                // ,width:100

                , cellMinWidth: 80
                , limits: [5, 10, 15, 20, 25, 30]
                , limit: "{:config('pages')}"
                , text: {
            none: '暂无数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        }
        , loading: true
                , id: 'testReload'
                , cols: [[
            {type: 'checkbox', fixed: 'left',}
            , {type:'numbers', width: 60, title: '序号'}
            , {field: 'id', width: 60, title: 'ID', sort: true, align: 'center'}
            , {field: 'user_username', width: 130, title: '用户昵称', align: 'center'}
            , {field: 'user_rel_name', width: 130, title: '姓名', align: 'center'}
            , {field: 'user_phone', width: '', title: '手机号码', align: 'center'}
            , {field: 'total_time', width: '', title: '公益时长', align: 'center'}
            , {field: 'sign_time', width: '', title: '签到时间', align: 'center'}
            , {field: 'sign_end_time', width: 130, title: '签退时间', align: 'center'}
            , {field: 'sign_status', width: 130, title: '签到状态', align: 'center',templet:"#activity_sh"}
            , {fixed: 'right', width: 200, title: '操作', align: 'center', toolbar: '#opeBar'}
        ]]
                ,done: function (res, curr, count) {
            $.each(res.data,function(index,item){
                $('#view_'+item['banner_id']).viewer({
                    url: 'data-original',
                });
            });
        }
    });

        //搜索表格重载
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where:$('#layuiForm').parseForm()
                });
            }

        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
<script type="text/html" id="activity_sh">
    {{# if(d.sign_status == 1){ }}
    <span style="color:#ec4758">未签到</span>

    {{# }else if(d.sign_status == 2){ }}
    <span style="color:#ec4758">签到</span>
    {{# } else {}}
    <span style="color:#ec4758">签退</span>
    {{# } }}
</script>
<script type="text/html" id="opeBar">
    {{# if(d.sign_status==3) { }}
    <a href="javascript:location.href = '{:url('sign')}?id={{d.id}}';" class="btn btn-primary btn-outline btn-xs"><i class="fa fa-paste"></i> 编辑</a>&nbsp;
    {{# } }}
</script>
</body>
</html>